package de.shortys.myhome.api.view.tree;

import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

public class ModuleViewTreeCellRenderer extends DefaultTreeCellRenderer {

	private static final long serialVersionUID = 1L;

	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
			boolean leaf, int row, boolean hasFocus) {
		ModuleViewTreeNode moduleViewTreeNode = (ModuleViewTreeNode) value;
		setText(moduleViewTreeNode.getTitle());
		setIcon(moduleViewTreeNode.getIcon());
		setOpaque(false);
		setBackground(new Color(0, 0, 0));
		setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
		if (selected) {
			setForeground(Color.decode("0x015da0"));
		} else {
			setForeground(Color.BLACK);
		}

		return this;
	}
}
